package controllers

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"os"
	"time"

	"github.com/gin-gonic/gin"
)

type Log struct {
}

func (this *Log) Get(c *gin.Context) {
	dir, _ := os.Getwd()
	suffixPath := fmt.Sprintf("%s%s.%s", "log", time.Now().Format("20060102"), "log")
	path := dir + "/runtime/logs/" + suffixPath
	result, _ := ioutil.ReadFile(path)
	str := string(result)
	c.String(http.StatusOK, str)
}
